<?php
// 重置密码页
// header("content-type:text/html;charset=utf-8");
$reID = $_POST['docID'];
$rePwd = $_POST['docPwd'];
$resetKey = $_POST['resetkey'];
include_once("conn.php");

$select = "SELECT * FROM doc_infos WHERE doc_ID = '" . $reID . "'";
$result_select = mysqli_query($connect_DB, $select);
$rows = mysqli_num_rows($result_select);
if ($rows != 0) {
    $doc_Info = mysqli_fetch_object($result_select);
    if ($resetKey === $doc_Info->doc_ResetKey) {
        $update = "UPDATE doc_infos SET doc_Password = '" . $rePwd . "',doc_ResetKey ='' WHERE doc_ID = '" . $reID . "'";
        if(mysqli_query($connect_DB, $update)){
            echo "<script>alert('重置密码成功！请返回登录！');location='doc_Login.html';</script>";
        }else{
            echo "<script>alert('重置密码失败！请稍后重试！');history.go(-1);</script>";
            // echo $update;
        }
    } else {
        echo "<script>alert('重置密钥核对失败！请联系管理员！');history.go(-1);</script>";
    }
}
if ($rows == 0) {
    echo "<script>alert('账号不存在！');history.go(-1);</script>";
    // echo $select;
}
    
$connect_DB->close();

?>
